/*
 * @Author: liyin 2179253556@qq.com
 * @Date: 2023-04-28 16:42:59
 * @LastEditors: liyin 2179253556@qq.com
 * @LastEditTime: 2023-05-17 08:48:13
 * @FilePath: \hl-registration-view\src\store\menus.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineStore } from 'pinia'
import { ref } from 'vue';

export const useMeanStore = defineStore('mean', () => {
  // 菜单数据
  const menuList = ref([]) as any
  const openeds = ref([]) as any
  // 权限数据
  const permList = ref([])
  const hasRoute = ref(false)


  const changeRouteStatus = (state: any) => {
    hasRoute.value = state
    sessionStorage.setItem("hasRoute", state)
  }
  const setMenuList = (menus: any) => {
    if (menus) {
      openeds.value[0] = menus[0].path
      menuList.value = menus
    }

  }
  const setPermList = (authoritys: any) => {
    permList.value = authoritys
  }
  const setOpeneds = (params: any) => {
    openeds.value[0] = params
  }
  return {
    persist: true,
    menuList,
    permList,
    hasRoute,
    openeds,
    changeRouteStatus,
    setMenuList,
    setPermList,
    setOpeneds
  }
})